﻿// Genius
// Copyright (C) 2016 Dirk Friedenberger, www.frittenburger.de
//   
// This source file is subject to the Microsoft Public License (Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Genius.Brain.Impl.BO;
using Genius.Brain.Impl.Strategy;
using Genius.Brain.Shared;
using Genius.Brain.Shared.BO;
using Genius.Brain.Shared.Strategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Genius.Brain.Impl.Locator
{
    public class Installer : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For<IGenius>().ImplementedBy<Genius>().LifestyleSingleton());
          
            container.Register(Component.For<ITextTokenizerStrategy>().ImplementedBy<TextTokenizerStrategy>().LifestyleSingleton());
            container.Register(Component.For<ITextMatcherStrategy>().ImplementedBy<TextMatcherStrategy>().LifestyleSingleton());

            container.Register(Component.For<ILanguageConstructorStrategy>().ImplementedBy<LanguageConstructorStrategyForDe>().Named("de").LifestyleSingleton());
            container.Register(Component.For<ILanguageConstructorStrategy>().ImplementedBy<LanguageConstructorStrategyForEs>().Named("es").LifestyleSingleton());
            container.Register(Component.For<ILanguageConstructorStrategy>().ImplementedBy<LanguageConstructorStrategyForEn>().Named("en").LifestyleSingleton());



            //kein Singleton, wegen Constructor(String)
            container.Register(Component.For<ITextParserStrategy>().ImplementedBy<TextParserStrategy>().LifestyleTransient());
            container.Register(Component.For<ITextFormaterStrategy>().ImplementedBy<TextFormaterStrategy>().LifestyleTransient());

            //JSon ' databases (kein Singelton, wg AddFile()
            container.Register(Component.For(typeof(IJsonDatabase<>)).ImplementedBy(typeof(JsonDatabase<>)).LifestyleTransient());
            //JSo's databases converter strategies
            container.Register(Component.For<IJsonConverterStrategy<ITokenDatabaseRecord>>().ImplementedBy<TokenDatabaseRecordJsonConverterStrategy>().LifestyleSingleton());


            //BO's
            container.Register(Component.For<IMessage>().ImplementedBy<Message>().LifestyleTransient());
            container.Register(Component.For<IDialog>().ImplementedBy<Dialog>().LifestyleTransient());
            container.Register(Component.For<IDialogContext>().ImplementedBy<DialogContext>().LifestyleTransient());
            container.Register(Component.For<IChannel>().ImplementedBy<Channel>().LifestyleTransient());
            container.Register(Component.For<IInstantMessaging>().ImplementedBy<InstanceMessaging>().LifestyleTransient());
            container.Register(Component.For<IText>().ImplementedBy<Text>().LifestyleTransient());
            container.Register(Component.For<ITextToken>().ImplementedBy<TextToken>().LifestyleTransient());
            container.Register(Component.For<IMatch>().ImplementedBy<Match>().LifestyleTransient());
            container.Register(Component.For<ITokenDatabaseRecord>().ImplementedBy<TokenDatabaseRecord>().LifestyleTransient());

        }
    }
}
